from coresales.models import logger
from coresales.salesInitDb import UpdateSales
from django.contrib.sitemaps import ping_google

from optparse import make_option
from django.core.management.base import BaseCommand
from settings import MEDIA_ROOT

class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option('--long', '-l', dest='long',
            help='Help for the long options'),
    )
    help = 'Help text goes here'

    def handle(self, **options):
        print MEDIA_ROOT
        updateSales=UpdateSales()
        updateSales.initSite()
        updateSales.fromProducts()
        print "Update from products"
        updateSales.fromXml()
        print "Update from xml"
        
        ping_google()
        logger.info("Ping search engines") 